<div class="modal-dialog modal-md">
    <form id="ajaxForm" method="post" class="form-horizontal" action="/admin/order/termination" data-validate="parsley">
        <input type="hidden" value="{{order.id}}" name="id">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">终止</h4>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label class="col-sm-3 control-label">操作类型</label>
                    <div class="col-sm-9">
                        <div class="row">
                            <div class="col-md-8 ">
                                <input type="hidden" name="operation" class="input-sm form-control" required readonly
                                    value="终止">
                                    <label class="control-label">终止</label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注类型</label>
                    <div class="col-sm-9">
                        <div class="row">
                            <div class="col-md-8 ">
                                <input type="hidden" name="remark_type" class="input-sm form-control" required readonly
                                    value="{{controller.referer()|get_pathname}}">
                                    <label class="control-label">{{controller.meta_title}}</label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">终止类型</label>
                    <div class="col-sm-9">
                        <div class="row">
                            <div class="col-md-8 ">
                                <select class="form-control input-sm" name="problem_type"{% if order.status != 0%}disabled {%endif%}>
                                    <option value="" style="display: none"></option>
                                    <option value="问题订单" {% if order.problem_type=='问题订单'%}selected{%endif%}>问题订单</option>
                                    <option value="其他" {% if order.problem_type=='' or order.problem_type=='其他'%}selected{%endif%}>其他</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">问题方姓名</label>
                    <div class="col-sm-9">
                        <div class="row">
                            <div class="col-md-8 ">
                                <select class="form-control input-sm" name="problem_userid" required {% if order.status != 0%}disabled {%endif%}>
                                    <option value="" style="display: none"></option>
                                    <option value="{{order.gongid}}" {% if order.problem_userid==order.gongid%}selected{%endif%}>{{order.gong_username}}</option>
                                    <option value="{{order.xuid}}" {% if order.problem_userid==order.xuid%}selected{%endif%}>{{order.xu_username}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                {%if order.problem_userid==order.xuid %}
                {% set problem_gsmc = order.xu_gsmc%}
                {% set problem_mobile = order.xu_mobile%}
                {%elif order.problem_userid==order.gongid%}
                {% set problem_gsmc = order.gong_gsmc%}
                {% set problem_mobile = order.gong_mobile%}
                {%endif%}
                <div class="form-group">
                    <label class="col-sm-3 control-label">问题方公司</label>
                    <div class="col-sm-9">
                        <div class="row">
                            <div class="col-md-8 ">
                                <input type="text" name="problem_gsmc" class="input-sm form-control" required readonly value="{{problem_gsmc}}">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">问题方电话</label>
                    <div class="col-sm-9">
                        <div class="row">
                            <div class="col-md-8 ">
                                <input type="text" name="problem_mobile" class="input-sm form-control" required 
                                readonly value="{{problem_mobile}}">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注</label>
                    <div class="col-sm-9">
                        <div class="row">
                            <div class="col-md-8 ">
                                <textarea class="form-control" placeholder="请填写备注信息，必填项。" name="remark_contents"
                                    style="height: 200px" required {% if order.status != 0%}disabled {%endif%}>{% if order.review_remark %}{{order.review_remark.remark_contents}}{%endif%}</textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <a href="javascript:;" class="btn btn-default" data-dismiss="modal">关闭</a>
                {% if order.status == 0%}
                <a href="javascript:;" class="btn btn-primary btn-s-md ajax-post" type="submit"
                    target-form="form-horizontal">确定</a>
                {%endif%}
            </div>
        </div><!-- /.modal-content -->
    </form>
</div><!-- /.modal-dialog -->
<script>
    $("select[name='problem_userid']").on("change", function (e) {
        var val = $(this).val();
        if (val == '{{order.xuid}}') {
            $("input[name='problem_mobile']").val('{{order.xu_mobile}}');
            $("input[name='problem_gsmc']").val('{{order.xu_gsmc}}');
        } else {
            $("input[name='problem_mobile']").val('{{order.gong_mobile}}');
            $("input[name='problem_gsmc']").val('{{order.gong_gsmc}}');
        }
    })
</script>